DatePicker.inherit("Control");

function DatePicker(node){
    this.Control(node);
	this.spanElement=document.getElementById(this.properties.getString("id"));
	this.textBox=this.properties.getObject("textBox");
	this.buttonForm=document.getElementById(this.properties.getString("buttonId"));
	this.hidden=this.properties.getObject("hidden");
	
	
    
	this.textBox.getEventHandler().registerListener("change", textChangedListener);
}

var textChangedListener={
        "onchange": function(eventArgs) {
                     
            this.hidden.setValue(this.textBox.getText());
        }
    }

/*
function DatePicker(spanId, textBox, buttonId){
	this.spanElement=document.getElementById(spanId);
	this.textBox=textBox;
	this.buttonForm=document.getElementById(buttonId);
}*/


DatePicker.prototype.getTextBox=function () {
	return this.textBox;
}

DatePicker.prototype.toString=function () {
	return this.textBox.toString();
}

DatePicker.prototype.clear=function () {
	this.textBox.setText("");//.clear();
	this.hidden.setValue("");	
}

DatePicker.prototype.setEnabled=function (enabled) {
    var img_el = this.buttonForm.getElementsByTagName("IMG")[0]
    img_el.disabled = !enabled;
	this.textBox.setEnabled(enabled);	
}

DatePicker.prototype.setVisible=function (value) {
	this.spanElement.style.visibility=value?"visible":"hidden";
}

DatePicker.prototype.getVisible=function () {
	return !(this.spanElement.style.visibility=="hidden");
}

DatePicker.prototype.populate=function (prefix, results) {
	this.textBox.setText(results.getValue(prefix+".text"));
}

DatePicker.prototype.getValue=function () {
	return this.textBox.getValue();
}

DatePicker.prototype.setValue=function (value) {

    this.hidden.setValue(value);
	return this.textBox.setValue(value);
}

DatePicker.prototype.getEventHandler=function () {
	return this.textBox.getEventHandler();
}
